﻿using System;

namespace Calculator
{
    class Calculation
    {
        static void Main(string[] args)
        {
            //按ppt上面来
            string s = "";
            int a = 0;
            int b = 0;

            Console.WriteLine("请输入一个数");
            s = Console.ReadLine();
            //这里应该判断一下后面的转换能否进行
            IsInteger(s);
            a = Int32.Parse(s);

            Console.WriteLine("请再输入一个数");
            s = Console.ReadLine();
            IsInteger(s);
            b = Int32.Parse(s);

            Console.WriteLine("请选择运算方式并输入相应符号");
            s = Console.ReadLine();
            //这个暂时没有找到怎么判断，只能在后面加

            Calculate(s, a, b);


        }


        //经网上查找方法和查阅书籍得知
        static bool IsInteger(string str)
        {
            try
            {
                int i = Convert.ToInt32(str);
                return true;
            }
            catch
            {
                Console.WriteLine("输入的不是整数，无法继续");
                return false;
            }
        }


        static void Calculate(string s,int x, int y)
        {
            int result = 0;
            switch( s){
                case "+":
                    result = x + y;
                    break;
                case "-":
                    result = x - y;
                    break;
                case "*":
                    result = x * y;
                    break;
                case "/":
                    result = x / y;
                    break;
                case "%":
                    result = x & y;
                    break;
                default:
                    Console.WriteLine("你是不是符号输错了");
                        break;
            }
            Console.WriteLine("{1}{0}{2}={3}", s,x,y,result);
        }

    }
}

//所查阅的网站为https://blog.csdn.net/dearbaba_8520/article/details/80418330?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_utm_term-1&spm=1001.2101.3001.4242